Create your identity card

Create your identity card that includes the following details: - Name: ..... - Surname: ...... - Age: ...... - University: ...... University - Department: Computer Programming - ID Number: ......


Guys i have to do it same to that one but with the new subjects i need your helps. How can i do it ? with "C"


#include <stdio.h>

int main()
{
//declare variables

int id;
int age;
char name[16];
char class_name[4];

//get information

printf("Enter ID: ");
scanf("%d",&id);

printf("Enter class_name: ");
scanf("%s",class_name);

printf("Enter name: ");
scanf("%s",name);

printf("Enter age: ");
scanf("%d",&age);

//printing out information given

printf("\n\n\nStudent ID : %d\n",id);
printf("Student name: %s\n",name);
printf("class name : %s\n",class_name);
getchar();
printf("Student age : %d\n",age);

printf("\n");

return 0;
}
Last edited on
Hello gokhanyildirim99,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

Along with the proper indenting it makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.

You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.


My first question is this a C or C++ program?

Next I see you have defined "class_name" as a 4 character array, so is the class name 3 or 4 characters? I it is 4 characters you will need to make it one larger for the terminating null (\0) that marks the end of the string.

Do you need a "name" and "surname" variables or will just one do?
Given the first line of your post I am thinking that you need the name in two parts.

The input part looks OK for now.

If the output is not what you want do it by hand and post what you want it to look like. You can use the output tag for this.

Andy
with c programming language
I need 2 variables
Last edited on
Hello gokhanyildirim99,

You are on the right path. You need to add a variable for the "surname" part then add to your "get information" section and then to the "printing out information given" section.

If you have any problems or questions post the revised code in a new message. DO NOT edit your original post with new code. this just confuses those who come in later.

Andy
Hello Handy Andy

thank you so much.
Hello Guys I did all of them... thank you so much again.

#include <stdio.h>

int main()
{

char name[6];
char surname[8];
int age;
char university[23];
char department[19];
int id;

printf("Enter Name:");
scanf("%s",name);

printf("Enter Surname:");
scanf("%s",surname);

printf("Enter Age:");
scanf("%d",&age);

printf("Enter University:");
scanf("%s",university);

printf("Enter Department:");
scanf("%s",department);

printf("Enter ID:");
scanf("%d",&id);


printf("\n");

return 0;
}
Topic archived. No new replies allowed.