Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int count;
- int main()
- {
- int i,a,b;
- a=5;
- b=6;
- count+=3;
- for(i=0;i<10;i++)
- {
- count++;
- printf(" %d",a);
- a=a+b;
- count+=2;
- }
- count++;
- printf("\n Count is %d \n",count);
- }
- 5 11 17 23 29 35 41 47 53 59
- Count is 34
- Press any key to continue
- //find max and min of 3
- #include<stdio.h>
- int count;
- int main()
- {
- int a,b,c;
- printf("Enter the 3 nos");
- scanf("%d %d %d",&a,&b,&c);
- count+=3;
- if(a>b && a>c)
- {
- printf("\nthe biggest no is %d",a);
- count+=2;
- }
- else if(b>c && b>a)
- {
- printf("\nthe biggest no is %d",b);
- count+=3;
- }
- else
- {
- printf("\nthe biggest no is %d",c);
- count+=3;
- }
- printf("\n count= %d ",count);
- }
- Output:
- BEST CASE
- Enter the 3 nos3 2 1
- the biggest no is 3
- count= 5 Press any key to continue
- WORST CASE
- Enter the 3 nos1 2 3
- the biggest no is 3
- count= 6 Press any key to continue
- //search
- #include<stdio.h>
- int count;
- int main()
- {
- int i,srch,a[10]={1,2,5,6,8,9,7,17,15,28},flag=0;
- printf("enter the number to search");
- scanf("%d",&srch);
- count+=3;
- for(i=0;i<10;i++)
- {
- count++;
- if(a[i]==srch)
- {
- printf("Element found at position %d ",i+1);
- flag=1;
- count+=3;
- break;
- }
- count++; // incremented for the if
- }
- count++; // incremented for the for
- if(flag==0)
- {
- printf("Not Found");
- count++;
- }
- count++; // incremented for the if
- printf("\n Count is %d \n",count);
- }
- OUTPUT:
- BEST CASE
- enter the number to search1
- Element found at position 1
- Count is 9
- Press any key to continue
- WORST CASE
- enter the number to search28
- Element found at position 10
- Count is 27
- Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment