Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C
// error check
#include<stdio.h>
#include<conio.h>

void main()
{
    int i,n;
    n=20;
    clrscr();
    for(n=0;i<n;i--){>
    printf("*");}
    getch();
}


nothing to adding in this code.
what can i do?
output is *************************20 star.
Posted
Updated 23-Oct-12 5:04am
v3
Comments
fjdiewornncalwe 23-Oct-12 11:05am    
What exactly is your question? Perhaps you can give more information because this doesn't make sense right now.
The way it stands right now, your program will produce output of 20 stars just as you have indicated. What kind of changes do you want to make?
Sandeep Mewara 23-Oct-12 14:01pm    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.

In your code,the variables "i" isn't initialize.
maybe you can change "for(i=0;i<n;i++)".>
 
Share this answer
 
Comments
nv3 23-Oct-12 11:48am    
nicely observed.
Your question is not clear and so is your English (sorry for indicating that...)
 
Share this answer
 
Comments
Nelek 23-Oct-12 16:20pm    
And this is not an answer... it is a comment (sorry for indicating that) ;P
Michael Haephrati 23-Oct-12 16:22pm    
You are right about that
If the output should be 20 stars (*), you can do it in the this way:
C
#include <stdio.h>
#include <string.h>
#include <conio.h>

int main ()
{
  char str[21]; //21 because 20 stars and '\0' at the end 
  strcpy (str,"*********************"); //fill 
  //or char str[21] = {"*********************"};
  //or char str[] = {"*********************"};  //automatically preserve the size
  printf(str);
  getch();
  return 0;
}


C - i almost forgot it ;)
 
Share this answer
 
v2
C++
#include <stdio.h>
#include <conio.h>

void main()
{
    clrscr();
    int n=20; while(n--) printf("*");
    getch();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900