Professional Documents
Culture Documents
PROGRAMMING
Date:
Aim:
To write efficient C code by adapting MISRA and CERT coding standards.
Software Requirement:
Ubuntu Linux distros
Procedure:
Develop a C program and execute using gedit in gcc compiler
Compile the developed C program in the terminal window using gcc compiler
Implement the MISRA C conding standard in the developed C program
Compile and Execute the MISRA C coding standard implemented C program
using gcc compiler
Compare the results using terminal window.
Commands:
For installing GCC:
sudo apt-get update
sudo apt-get install build-essential manpages-dev
To write programs:
Install gedit text editor
sudo apt-get install gedit
To open text editor
gedit myfirstprog.c
It will create and open a file named myfirstprog.c, type the C program in text
editor.
To compile and Run:
$ gcc –o myfirstprog myfirstprog.c
./myfirstprog
Required Rules:- 122 Required Rules – must follow the rules - mandatory
#include<stdio.h> #include<stdio.h>
void main() void main()
{ {
int a; int a=50,
printf(“Hello!\n”); printf(“Hello!\n”);
printf(“Enter Reg. NO:\n”); printf(“Enter Reg. No.\n”);
scanf(“%d”,&a); scanf(“%d”,&a);
printf(“Your Reg. No. Is:%d”,a); printf(“Your Reg. No. Is:%d”,a);
} }
#include<stdio.h> #include<stdio.h>
void main() void main()
{ {
const a=50; const int a=50;
printf(“integer constant:%d”,a); printf(“integer constant:%d”,a);
return 0; return 0;
} }
Rule 9.1: Output
Result:
Thus the C program for MISRA C standard and CERT C standard is developed
and executed in Ubunto Desktop Distros using gcc compiler.