Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

asa76

@asa76
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • While loop not working on C.
    A asa76

    The first problem is that the variable i has not been initialized. The second problem is that you are checking the wrong array index. See the comments in the modified version of your code below.

    #include #include int main(){

    int num\[50\], i, j;
    int count = 0;
    
    i = 0;  // Added this
    printf("Enter your integer: \\n");
    
    do{
    	scanf(" %d", &num\[i\]);
    	count++;
    	
    }while(num\[i++\]!=0);  // Changed this
    
    for(j=1; j<= count; j++){
    	
    	if(num\[1\] > num\[j\]){
    		num\[1\] = num\[j\];
    	}
    }
    
    printf("%d is the greatest of them all !", num\[0\]);
    
    return 0;
    

    }

    C / C++ / MFC data-structures
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups