Showing posts with label C language. Show all posts
Showing posts with label C language. Show all posts

Frequently Asked Top 20 C programs in Interview

Frequently Asked C Programs


Here You Can get Frequently asked C programs in the interview. These programs can be asked from Basic C language, array, string, pointer, linked list, file handling etc. Let us Learn the list of c programs.

1) Fibonacci Series

Write a program in C Language to print fibonacci series without using recursion and using recursion.
Input: 10
Output: 0 1 1 2 3 5 8 13 21 34

2) Prime number

Write a program in C Language to check prime number.
Input: 44
Output: not prime number
Input: 7
Output: prime number

3) Palindrome number

Write a Program in c Language to check palindrome number.
Input: 329
Output: not palindrome number
Input: 12321
Output: palindrome number

4) Factorial

Write a Program in C language to print factorial of a number.
Input: 5
Output: 120
Input: 6
Output: 720

5) Armstrong number

Write a program in C language to check armstrong number.
Input: 153
Output: armstrong
Input: 22
Output: not armstrong

6) Sum of Digits

Write a program in C language to print sum of digits.
Input: 234
Output: 9
Input: 12345
Output: 15

7) Reverse Number

Write a program in C language to reverse given number.
Input: 123
Output: 321

8) Swap two numbers without using third variable

Write a program to swap two numbers without using third variable.
Input: a=10 b=20
Output: a=20 b=10

9) Print "hello" without using semicolon

Write a program in C language to print "hello" without using semicolon

10) Assembly Program in C

Write a program in C language to add two numbers using assembly code.

11) C Program without main() function

Write a program in C to print "Hello" without using main() function.

12) Matrix Multiplication

Write a program In C language to print multiplication of 2 matrices.
Input:
first matrix elements:
1 1 1
2 2 2
3 3 3
second matrix elements
1 1 1
2 2 2
3 3 3
Output:
multiplication of the matrix:
6 6 6
12 12 12
18 18 18

13) Decimal to Binary

Write a program in C language to convert decimal number to binary.
Input: 5
Output: 101
Input: 20
Output: 10100

14) Alphabet Triangle

Write a program in C language to print alphabet triangle.
Output:
     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA

15) Number Triangle

Write a program in C language to print number triangle.
Input: 7
Output:
enter the range= 6
      1
     121
    12321
   1234321
  123454321
 12345654321

16) Fibonacci Triangle

Write a program in C language to generate fibonacci triangle.
Input: 5
Output:
1
1 1 
1 1 2 
1 1 2 3 
1 1 2 3 5  

17) Number in Characters

Write a program in C language to convert number in characters.
Input: 5
Output: five
Input: 203
Output: two zero three

C language tutorial

language tutorial


C language is a generic, procedural computer programming language. In 1972, in order to transplant and develop the UNIX operating system, Dennis Ritchie in Bell telephone lab design and development of the C language.
C language is a widely used computer language, which is as popular as the Java programming language, both of which are widely used among modern software programmers.
The current latest C language standard for C11, before its C language standard for C99.

Who is suitable for reading this tutorial?
This tutorial is designed for software programmers who need to learn C from scratch. This tutorial will give you an idea of ​​the C language to enhance your own level of expertise.
Before you read this tutorial, you need to know the knowledge:
Before you start this tutorial, you need a basic understanding of computer programming terminology. A basic understanding of any programming language will help you understand the C language programming concepts and help speed your learning progress.
Compile / execute C program

Examples:

#include < stdio.h >
Int main ( ) 
{ / * my first C program * / 
printf ( " Hello, World! \ N " ) ;
return 0 ;
}

Example Analysis:
·         All C language programs need to include the main () function. The code starts from the main () function.
·         / * ... * / for annotations.
·         Printf () is used to format the output to the screen. The printf () function is declared in the "stdio.h" header file.
·         Stdio.h is a header file (standard input and output header file), #include is a preprocessing command, used to introduce the header file. When the compiler encounters the printf () function , a compile error occurs if the stdio.h header file is not found .

·         Return 0; statement is used to indicate exit procedure.

C program structure | Compilation and Execution Process of C Program

program structure
Before we learn the basic building blocks of the C language, let's take a look at a minimal C program structure, which can be used as a reference in the following sections.
C Hello World instance
The C program mainly consists of the following:
·         Preprocessor directive
·         function
·         variable
·         Statement & expression
·         Annotations
Let's look at a simple code that can output the word "Hello World":
Examples
#include < stdio.h >
Int main ( )
 { 
/ * my first C program * / 
printf( " Hello, World! \ N " )
return 0 ;
}
Next we explain the above procedure:
1.     The first line of the program #include <stdio.h> is a preprocessor directive that tells the C compiler to include the stdio.h file before actually compiling.
2.     The next line int main () is the main function, the program from here to start.
3.     The next line /*...*/ will be ignored by the compiler, where the contents of the program will be placed. They are called annotations of the program.
4.     The next line, printf (...), is another function that is available in C and displays the message "Hello, World!" On the screen.
5.     The next line returns 0; terminates the main () function and returns the value 0.
Compile & execute C program
Let's take a look at how to save the source code in a file and how to compile it and run it. Here are the simple steps:
1.     Open a text editor and add the above code.
2.     Save the file as hello.c .
3.     Open the command prompt and go to the directory where the saved file is located.
4.     Type gcc hello.c , enter the carriage return, compile the code.
5.     If there is no error in the code, the command prompt jumps to the next line and generates the a.out executable.
6.     Now, type a.out to execute the program.
7.     You can see "Hello World" on the screen .
$ Gcc hello.c
$ ./a.out
Hello, World!

Make sure that your path already contains the gcc compiler and that you are running it in the directory containing the source file hello.c.

Introduction to C language

C language is a common high-level language, originally designed by Dennis Ritchie in the Bell Labs for the development of UNIX operating system. The C language was first implemented in 1972 on the DEC PDP-11 computer.

In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K & R standard.

UNIX operating system, C compiler, and almost all UNIX applications are written in C language. For a variety of reasons, the C language has now become a widely used professional language.

·         Easy to learn.
·         Structured language.
·         It produces efficient programs.
·         It can handle the underlying activities.
·         It can be compiled on a variety of computer platforms.

About C


·         The C language was invented for the purpose of writing a UNIX operating system.
·         C language is based on the B language, B language is probably introduced in 1970.
·         The C language standard was developed in 1988 by the American National Standards Institute (ANSI).
·         As of 1973, the UNIX operating system was written entirely in C language.
·         At present, C language is the most widely used system programming language.
·         Most of the advanced software is implemented using the C language.
·         Today's most popular Linux operating system and RDBMS (Relational Database Management System: relational database management system) MySQL are written in C language.

Why use C?


C language was originally used for system development work, especially the composition of the operating system procedures. Since the code generated by the C language runs almost as fast as the code written in the assembly language, the C language is used as the system development language. Here are a few examples of using C:
·         operating system
·         Language compiler
·         Assembler
·         text editor
·         printer
·         Network drive
·         Modern procedures
·         database
·         Language interpreter
·         Physical tools

C program


A C language program, which can be 3 lines or millions of lines, can be written in one or more text files with the extension ".c" , for example, hello.c . You can use "vi" , "vim" or any other text editor to write your C program.
This tutorial assumes that you already know how to edit a text file and how to write the source code in the program file.

C11


C11 (also known as C1X) refers to ISO standard ISO / IEC 9899: 2011, is the latest C language standard. Prior to its C language standard for C99.

New features


·         Alignment normalization (including the _Alignas notation, the alignof operator, the aligned_alloc function, and the <stdalign.h> header file).
·         _Noreturn function tag, similar to gcc __attribute __ ((noreturn)).
·         _Generic keywords.
·         Multithreading support, including:
_Thread_local storage type identifier, <threads.h> header file, which contains the thread creation and management functions.
_Atomic type modifier and <stdatomic.h> header file.
·         Enhanced Unicode support. Enhanced Unicode support based on the C Unicode Technical Report ISO / IEC TR 19769: 2004. Including the char16_t and char32_t data types for UTF-16 / UTF-32 encoding, providing the header file <uchar.h> containing the unicode string conversion function.
·         Removed the gets () function, using a new, more secure function gets_s () instead.
·         Added a border check function interface that defines new security functions such as fopen_s (), strcat_s (), and so on.
·         Added more floating point processing macros (macros).
·         Anonymous structure / consortium support. This gcc already exists, C11 will be introduced into the standard.
·         Static assertions, _ Static_assert (), are processed after interpreting #if and #error.
·         New fopen () mode, ("... x"). Similar to POSIX in the O_CREAT | O_EXCL, in the file lock is more commonly used.

·         Added the quick_exit () function as a third way to terminate the program. You can do the least cleanup when exit () fails.


History of C Programming Language: Click Here

History of C Programming Language

C Programming Language tutorial in Hindi



Popular Posts