upsidedown

daa1

Jan 19th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.67 KB | None | 0 0
  1. //IF-ELSE(EVEN ODD)
  2. #include<iostream.h>
  3. int count=0;
  4. void main()
  5. {
  6.     int n;
  7.     count++;
  8.     cout<<"enter the value of n\n";
  9.     cin>>n;
  10.     count+=2;
  11.     if(n%2==0)
  12.     {
  13.         cout<<"the no. is even";
  14.         count++;
  15.     }
  16.     else
  17.     {
  18.         cout<<"the no. is odd";
  19.         count++;
  20.     }
  21.     count++;
  22.     cout<<"\ncount=\t"<<count;
  23. }
  24.  
  25. OUTPUT
  26.  
  27. EVEN
  28. enter the value of n
  29. 2
  30. the no. is even
  31. count=  5
  32. Press any key to continue
  33.  
  34. ODD
  35. enter the value of n
  36. 3
  37. the no. is odd
  38. count=  5
  39. Press any key to continue
  40. ----------------------------------------------------
  41.  
  42. //FOR(ADDN)
  43. #include<iostream.h>
  44. int count=0;
  45. void main()
  46. {
  47.   int total,a,b,i;
  48.   count++;
  49.     for(i=0;i<5;i++)
  50.         {
  51.           count++;
  52.           total=0;
  53.           a=5;
  54.           b=6;
  55.           total=a+b;
  56.           count+=4;
  57.         }
  58.         count++;
  59.         cout<<"count=\t"<<count;
  60. }
  61.  
  62. OUTPUT
  63. count=  27
  64. Press any key to continue
  65. --------------------------------------------------
  66. //FOR IF-ELSE(SEARCHING)
  67. #include<stdio.h>
  68. int count= 0;
  69. void main()
  70. {
  71.     int a[5]={5,6,7,8},
  72.     n,flag=0,i;
  73.     count++;
  74.     printf("enter the no to be searched");
  75.     scanf("%d",&n);
  76.     count+=2;
  77.     for(i=0;i<4;i++)
  78.     {
  79.         count++;
  80.         if(a[i]==n)
  81.         {
  82.             printf("the no. was found at %d\n",i);
  83.             flag=1;
  84.             count+=3;
  85.             break;
  86.        
  87.         }count++;
  88.     }count++;
  89.     if(flag==0)
  90.     {
  91.         count++;   
  92.         printf("the no was not found\n");
  93.     }count++;
  94.     printf("the cout is %d\n",count);
  95. }
  96.  
  97. OUTPUT
  98. best
  99. enter the no to be searched5
  100. the no. was found at 0
  101. the cout is 9
  102. Press any key to continue
  103.  
  104. inter
  105. enter the no to be searched7
  106. the no. was found at 2
  107. the cout is 13
  108. Press any key to continue
  109.  
  110. worst
  111. enter the no to be searched8
  112. the no. was found at 3
  113. the cout is 15
  114. Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment