Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

the program is not runing in C

Status
Not open for further replies.

sxy

Member
Code:
#include <stdio.h>
int multiplication(int a,int b)
{
int c;
c=a*b;
return c;
}
void main(void)
{
int r;
r = multiplication(2,8);
printf(“%d”,r);
}

I should get 16 but it is not runing.
why?
thanks a lot
 
Should this :

Code:
for(int i=0;i<10;i++)
    {
    scanf("%s",inpt);
    rollNo = atoi(inpt);
    }

be this :

Code:
for(int i=0;i<10;i++)
    {
    scanf("%s",inpt);
    rollNo[i] = atoi(inpt);
    }

Also do same for rollNo in print statement, eg use as array element....


Regards, Dana.
I'm having a bad day.. You are correct... I copied it from the online editor THEN took out the array content???? Loosing the piggin plot here...
 
Hi
How I can download visual studio 2022
in order to use C language
and C# language?
whenever I try to download visual studio 2022;
It says: "The installation isn't complete"
so I can't use C or C #.
thanks.
 
Hi
How I can download visual studio 2022
in order to use C language
and C# language?
whenever I try to download visual studio 2022;
It says: "The installation isn't complete"
so I can't use C or C #.
thanks.
How would we know whats wrong... There must be an error message at least...
Are you on win 10? did you let it install all the packages?? We can't see your display from here..
 
Thanks a lot for your answer.
I use windows 11.
The message says: that it didn't succeed to install part of the packages,
and that it the reason that I can't use C or C#.
 
#include<stdio.h>
void main()
{

int a[3][4]={3,4,7,1,-1,2,-4,7,4,7,0,-9};
int count=0,sum=0, i,j ;
//clrscr();
for(i=0;i<3,i++)
for(j=0;j<4;j++)
{
printf(“%5d”,a[j]);
if(j==4){
printf("\n");
}
if (a[j]>1&&a[j]<7)
count++;
}
printf(“\nthe count of numbers that greater than 1 and less than 7
= %d”,count);
for(j=0;j<4;j++)
sum=sum+a[0][j];
printf(“\n The sum of number in row 1 = %d”,sum);
}
Why the program isn't runing?
thanks a lot
 
From a quick look:

a[ ][ ] is a two dimensional array, but in some places you only have a single subscript, eg. a[j]


for(j=0;j<4;j++)
j range 0-3

if(j==4){
j should never be 4 within the loops....


And probably others, those are just the obvious ones.
 
#include<stdio.h>
int main(){


int a[3][4]={3,4,7,1,-1,2,-4,7,4,7,0,-9};
int count=0,sum=0, i,j ;
//clrscr();
printf("Two dimensional array elements:\n");
for(i=0;i<3;i++) {
for(j=0;j<4;j++) {

printf(“%5d”, a[j]);
if(j==3){
printf("\n");
}
}
}
return 0;
}
This program is also not running although I fixed the error:
f(j==4) to f(j==3).
thanks a lot
 
Last edited:
You can check your own code here :


1667558928660.png



Regards, Dana.
 
#include<stdio.h>
int main()
{
int a;
//clrscr();
printf(“Enter integer number for a”);
scanf("%d",&a);
if(a>0)
outp(0x300,0x0f);
else
outp(0x300,0xf0);
return 0;
}
Hi
why the program is not runing?
thanks a lot
 
Thanks for your answer.
But it doesn't work with outp32 also.
Here is the code:
#include<stdio.h>
int main()
{
int a;
//clrscr();
printf(“Enter integer number for a”);
scanf("%d",&a);
if(a>0)
outp32(0x300,0x0f);
else
outp32(0x300,0xf0);
}
thanks a lot
 
There is a library for out()and out32() but I very much doubt an online tool will use it...
I very much doubt win 10 would let you use them either..

I used to use out32() when I printed to the parallel port on win XP ( parallel port also now obsolete lol.. )
 
There is a library for out()and out32() but I very much doubt an online tool will use it...
I very much doubt win 10 would let you use them either..

I used to use out32() when I printed to the parallel port on win XP ( parallel port also now obsolete lol.. )
Exactly, they are unusable on modern hardware and non-portable to different systems anyway.
 
Whenever I try to download Visual Studio 2022

in order to use C language,
It says: "Couldn't install Microsoft Visualcpp.Redist.14"
and also it says: "Setup completed with warnings".
What can I do?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top