Write a C-program that will display your name and your registration number in different line.


 

To answer this question, you need to first have a good understanding of C-program and how to output statement in C-Programming Language. Now let's understand this one after the other.

What is C-Programming Language


C Programming Language was developed by Dennis Ritchie in 1972. It is a well constructed programming language and a low programming level language close to machine language. C Programming Language is widely used in the software development field. It is a procedure and structure-oriented language. C Programming Language has the full support of various operating systems and hardware platforms. Many compilers are available for executing programs written in 'C'. A compiler compiles the source file and generates an object file.

Output Statement in C-programming Language

All programming languages have different output function that are use to output statement to the user even though some programming language can use same output function. The C-programming language use the printf() function to output statement to the users.

Solution 1

#include <stdio.h>
int main()
{
printf("Name: Easy Code \x0A Registration number: bsu/sc/cmp/11/11917.\x0A");
return 0;
}

Remember to Replace Easy Code with your name, and bsu/sc/cmp/11/11917 with your registration number. 0A in hexadecimal is 10 in Decimal and is the ASCII value of new line character we can use \x0A, 10 or \n  to output values in new line.

Solution 2 using new line excape character ( \n)

#include <stdio.h>
int main()
{
printf("Name: Easy Code \n Registration number: bsu/sc/cmp/11/11917.\n");
return 0;
}

Solution 3 using %c and ASCI Code

#include <stdio.h>
int main()
{
printf("Name: Easy Code%cRegistration number: bsu/sc/cmp/11/11917.%c",0x0A,0x0A);
return 0;
}

Solution 4

#include <stdio.h>
int main()
{
printf("Name: Easy Code%cRegistration number: bsu/sc/cmp/11/11917.%c",10,10);
return 0;
}

Solution 5

#include <stdio.h>
int main()
{
printf("Name: Easy Code%cRegistration number: bsu/sc/cmp/11/11917.%c",'\n','\n');
return 0;
}





Ameh Joseph Onyeke

Hello and welcome to my blog! My name is Ameh Joseph Onyeke a passionate educator and tech enthusiast with a BSc in Computer Science from Benue State University, a PGDE from the University of Maiduguri, and a Master’s in Software Engineering from Bayero University Kano. My journey blends a strong foundation in computing with a love for teaching, aiming to simplify complex tech concepts for learners at all levels. Through this blog, I provide answers and insights across 10+ programming languages to support students and tech enthusiasts in building their skills and confidence. Whether you're solving coding problems or sharpening your programming abilities, this blog is here to guide you. Let’s learn and grow together!

Post a Comment

Previous Post Next Post