C Questions Answers-C loops (PartII)


C loops (PartII)

1. Change the following C code from using a while loop to for loop:
x=1;
while(x<10){
  printf("%d\t",x);
  ++x;
}
Check answer 2. Change the following C code from a while loop to a for loop:
int x;
scanf("%d",&x);
while(x!=10){
  printf("%d\t",x);
  scanf("%d",&x);
}
Check answer 3. What would be the output from the following C code segment?
x=10;
while(x>5){
  printf("%d\n",x);
  x--;
}
Check answer 4. Change the following C code from a for loop to a while loop:
for(i=1;i<50;i++)
  printf("%d\t",i);
Check answer 5. What would be printed from the following C code segment?
for(i=20;i>0;i-=2)
  printf("%d\t",i);
Check answer 6. What would be printed from the following C code segment?
for(x=1;x<=5;x++){
 for(y=1;y<=x;y++)
  printf("%d\t",x);
printf("\n");
}
Check answer 7. Change the following C code from a do while loop to a while loop:
x=0;
do{
  printf("%d\t",x);
  x++;
 }while(x<10);
Check answer


Comments

tesfahiwet comment

 tesfahiwet

good and grea one.


2017-05-03
hemanth comment

 hemanth

these questtions are like where we do mistakes
nice set
keep it up


2017-02-13
brex comment

 brex

keep it up


2017-01-26
rolly comment

 rolly

its is a very helpfull to me...


2014-07-18



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.