8. Assignment 8
/---------------------------------/
(1)
#include<stdio.h>
void main()
{
int r,num,c=0;
printf("Enter a number : ");
scanf("%d",&num);
L1:
r=num%10;
if(r%2!=0)
c++;
num=num/10;
if(num>0)
goto L1;
printf("%d\n",c);
}
/---------------------------------/
(2)
#include<stdio.h>
void main()
{
int r,num,c=0;
printf("Enter a number : ");
scanf("%d",&num);
L1:
r=num%10;
if(r>5)
c++;
num=num/10;
if(num>0)
goto L1;
printf("%d\n",c);
}
/---------------------------------/
(3)
#include<stdio.h>
void main()
{
int r,num,sum=0,c=0;
printf("Enter a number : ");
scanf("%d",&num);
L1:
r=num%10;
if(r%2==0)
sum=sum+r;
num=num/10;
if(num>0)
goto L1;
printf("%d\n",sum);
}
/---------------------------------/
(4)
#include<stdio.h>
void main()
{
int r,num,sum=0,c=0;
printf("Enter a number : ");
scanf("%d",&num);
L1:
r=num%10;
sum=sum+r;
num=num/10;
if(num>0)
{
c++;
if(c<=2)
goto L1;
}
printf("%d\n",sum);
}
/---------------------------------/
(5)
#include<stdio.h>
void main()
{
int a=1,i=0;
L1:
a=a+i;
printf("%d ",a);
++i;
if(a<22)
goto L1;
printf("\n");
}
/---------------------------------/
(6)
#include<stdio.h>
void main()
{
int a=-13,i=5;
printf("%d ",a);
L1:
a=a+i;
printf("%d ",a);
i--;
if(a<2)
goto L1;
printf("\n");
}
Comments
Post a Comment