Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IF-ELSE(EVEN ODD)
- #include<iostream.h>
- int count=0;
- void main()
- {
- int n;
- count++;
- cout<<"enter the value of n\n";
- cin>>n;
- count+=2;
- if(n%2==0)
- {
- cout<<"the no. is even";
- count++;
- }
- else
- {
- cout<<"the no. is odd";
- count++;
- }
- count++;
- cout<<"\ncount=\t"<<count;
- }
- OUTPUT
- EVEN
- enter the value of n
- 2
- the no. is even
- count= 5
- Press any key to continue
- ODD
- enter the value of n
- 3
- the no. is odd
- count= 5
- Press any key to continue
- ----------------------------------------------------
- //FOR(ADDN)
- #include<iostream.h>
- int count=0;
- void main()
- {
- int total,a,b,i;
- count++;
- for(i=0;i<5;i++)
- {
- count++;
- total=0;
- a=5;
- b=6;
- total=a+b;
- count+=4;
- }
- count++;
- cout<<"count=\t"<<count;
- }
- OUTPUT
- count= 27
- Press any key to continue
- --------------------------------------------------
- //FOR IF-ELSE(SEARCHING)
- #include<stdio.h>
- int count= 0;
- void main()
- {
- int a[5]={5,6,7,8},
- n,flag=0,i;
- count++;
- printf("enter the no to be searched");
- scanf("%d",&n);
- count+=2;
- for(i=0;i<4;i++)
- {
- count++;
- if(a[i]==n)
- {
- printf("the no. was found at %d\n",i);
- flag=1;
- count+=3;
- break;
- }count++;
- }count++;
- if(flag==0)
- {
- count++;
- printf("the no was not found\n");
- }count++;
- printf("the cout is %d\n",count);
- }
- OUTPUT
- best
- enter the no to be searched5
- the no. was found at 0
- the cout is 9
- Press any key to continue
- inter
- enter the no to be searched7
- the no. was found at 2
- the cout is 13
- Press any key to continue
- worst
- enter the no to be searched8
- the no. was found at 3
- the cout is 15
- Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment