#include<string.h>
#include <conio.h>
#include <stdio.h>
struct safal{
char name[100];
int age;
int roll;
char address[100];
}f[100];
void main() {
int i, n;
printf("Enter the amount of student : ");
scanf("%d", &n);
printf("NAME AGE ROLL-NO ADDRESS\n");
for(i==0 ; i<n ; i++){
scanf("%s %d %d %s", f[i].name, &f[i].age, &f[i].roll, f[i].address);
}
printf("\n**************************************************************\n");
printf("NAME \t AGE \t ROLL-NO \t ADDRESS \n");
for(i==0 ; i<n ; i++){
printf("%s \t %d \t %d \t %s \n", f[i].name, f[i].age, f[i].roll, f[i].address);
}
printf("\n**************************************************************\n");
printf("\n\nONLY STUDENT FROM BHARATPUR\n");
printf("NAME \t AGE \t ROLL-NO \t ADDRESS \n");
for(i == 0 ; i<n ; i++){
if(strcmp(f[i].address,"Bharatpur") == 0){
printf("%s \t %d \t %d \t %s \n", f[i].name, f[i].age, f[i].roll, f[i].address);
}
}
printf("\n**************************************************************\n");
printf("\n\nONLY STUDENT WHO ARE ADULT\n");
printf("NAME \t AGE \t ROLL-NO \t ADDRESS \n");
for(i == 0 ; i<n ; i++){
if(f[i].age > 18){
printf("%s \t %d \t %d \t %s \n", f[i].name, f[i].age, f[i].roll, f[i].address);
}
}
getch();
}
#The Code isn't running, plz help
16 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
!f
#include <conio.h>
#include <stdio.h>
#include <string.h>
struct safal {
char name[100];
int age;
int roll;
char address[100];
} f[100];
void main() {
int i, n;
printf("Enter the amount of student : ");
scanf("%d", &n);
printf("NAME AGE ROLL-NO ADDRESS\n");
for (i == 0; i < n; i++) {
scanf("%s %d %d %s", f[i].name, &f[i].age, &f[i].roll, f[i].address);
}
printf("\n**************************************************************\n");
printf("NAME \t AGE \t ROLL-NO \t ADDRESS \n");
for (i == 0; i < n; i++) {
printf("%s \t %d \t %d \t %s \n", f[i].name, f[i].age, f[i].roll,
f[i].address);
}
printf("\n**************************************************************\n");
printf("\n\nONLY STUDENT FROM BHARATPUR\n");
printf("NAME \t AGE \t ROLL-NO \t ADDRESS \n");
for (i == 0; i < n; i++) {
if (strcmp(f[i].address, "Bharatpur") == 0) {
printf("%s \t %d \t %d \t %s \n", f[i].name, f[i].age, f[i].roll,
f[i].address);
}
}
printf("\n**************************************************************\n");
printf("\n\nONLY STUDENT WHO ARE ADULT\n");
printf("NAME \t AGE \t ROLL-NO \t ADDRESS \n");
for (i == 0; i < n; i++) {
if (f[i].age > 18) {
printf("%s \t %d \t %d \t %s \n", f[i].name, f[i].age, f[i].roll,
f[i].address);
}
}
getch();
}
What do you expect your code to do and where doesn't your code behave as it's supposed to?
i am not getting input prompt
I should be able to enter the name age roll and address at the given f structure, array but somehow i am not able to
@tacit reef can you help me in this
@quasi onyx Look at your for-loops.
You're doing:
for (i == 0; i < n; i++)
```But you should be doing
```c
for (i = 0; i < n; i++)
I'm surprised there isn't a warni... nevermind, you compile without warnings...
;compile -Wall -Wextra -Wpedantic
int i = 0;
for (i == 0; i < 10; i++) {
}
Compiler Output
<source>: In function 'main':
<source>:5:8: warning: statement with no effect [-Wunused-value]
5 | for (i == 0;
| ~~^~~~
elmonkeking#0000 | 35ms | c | x86-64 gcc 13.1 | godbolt.org
@quasi onyx Yeah...
Next time enable warnings (i.e. -Wall -Wextra -Wpedantic). If you had them enabled you would've solved this yourself in no time.
!solve