TRENDING NEWS

POPULAR NEWS

Help Me To Solve This C Language Problem

Please help me to solve these problem using c,java,c#?

// The "Okaba" class.
import java.util.*;
import java.io.*;
public class Okaba
{
public static void main (String [] args) throws IOException
{
boolean buildings [] [] = new boolean [8] [8];

BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

System.out.print ("Enter number of marines: ");
int marines = Integer.parseInt (br.readLine ());

for (int j = 0 ; j < marines ; j++)
{
System.out.print ("Enter x position for marine " + (j+1) + " : ");
int x = Integer.parseInt (br.readLine ());
x = x - 1;

System.out.print ("Enter y position: for marine " + (j+1) + " : ");
int y = Integer.parseInt (br.readLine ());
y = y - 1;

for (int rows = 0 ; rows < buildings.length ; rows++)
{
buildings [rows] [y] = true;
}

for (int cols = 0 ; cols < buildings [0].length ; cols++)
{
buildings [x] [cols] = true;
}
}

int count = 0;

for (int rows = 0 ; rows < buildings.length ; rows++)
{
for (int cols = 0 ; cols < buildings [0].length ; cols++)
{
if (buildings [rows] [cols])
{
count++;
}
}
}

System.out.println ("Number of buildings occupied: " + count);

} // main method
} // Okaba class

How do I solve difficult problems in c language?

Think more , do less complex tasks first and then move towards more complex ones.The way to solve any problem is,steps:State what the problem iswrite an algorithm for the problem (like in which all way you can find the solution)implement the algorithm using c or any other programming language.Or you could split the task into number of simpler smaller tasks (The Divide and Conquer Policy).Feel free to contact me, always happy to help.

What are the best sites to solve the problems on C and C++?

If you want to solve algorithmic problems in C/C++,then go for SPOJ (  Sphere Online Judge (SPOJ) ).It will give you an excellent and exhaustive collection of all algorithms you have seen so far.

Which programming problem we can solve in c++ but not in c?

All those problems which occur due to non-object oriented language can be solved in C++.In C, I cannot group related functions and data together while I C++ I can. After all that is what Encapsulation is all about. Grouping Data and related functions togetherIn C, I cannot reuse a part of code and tailor it according to my requirements. But in C++ I can. Inheritance is for that only.In C, I can't have a "thing" to take more than one form, without me knowing its form at runtime. But C++ allows me to do that. Polymorphism is about taking more than one form.

How to solve determinant in c programming language using recursion or is there any site which has solution?

/*to get determinant value of a 3x3 matrix*/
#include
#include
#include
main()
{
int a[3][3],i,j,k,p,sum=0;
clrscr();
printf("enter elements of a 3x3 matrix");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}}
/*determinant value*/
for(i=0;i<3;i++)
{
j=1;
if(i!=0)
{
j=0;
}
k=2;
if(i==2)
{
k=1;
}
p=pow(-1,i);
sum=sum+p*( (a[0][i])* ((a[1][j]*a[2][k])-(a[1][k] * a[2][j]) ) ) ;
}
printf("\nthe determinant value is %d",sum);
getch();
}

Hope this program'll help u. But this program is limited for 3x3 matrices only. If u want to find determinant of any NxN matrix (generalized case), u have to use "calloc" function.

What is the best website for problem solving in C?

If you wants to improve coding skills for Campus Placements then go for Sphere Online Judge (SPOJ) and http://geeksforgeeks.com that would be enough to get placed in a good company but if you wants to become a competitive coder then go for Codechef.com and If your only aim is to learn Programming language i.e C then dont think just go for HackerRank and Let us C textbook.

What are some real world problems that programming can solve? (Using C)

Any mathematical or decision problem would be an optimistic answer, however, it is somewhat true. If there is no bound on time and space, any of the above-mentioned problems can be solved. (There's a whole branch that deals with this possibility of solving and not solving called Complexity Theory; you might want to read about it.)Talking specifically about your question, there are various real world applications of C. Many of the programs that we see today, are written in Python (for ease), but ran on C for performance. (Cython) To generalise, if a task requires high efficiency with minimal resources, C (and C++) is preferred. (Understand that a language is just a medium for communication. If you have many options, you choose the one that suits you, and is efficient.)Lastly, those who do competitive coding will know how things are applied in real world. Let it be updating the standings in a competition, calculating trajectory, etc. There's a lot to try coding on, give everything a try. :D

Where can I solve problems on C programming as a beginner?

You can practice on codechef.com, spoj.com, hackerearth.com and also on topcoder.com. If you're just starting, try solving the easiest level problems. There are also many websites like ACPC, Google Code Jam, etc which have questions of previously organized coding competitions. You can try solving these questions also. You'll find many such websites like the ones that I've mentioned, online. All the best! :)

I need C programming help asap! (Problem #5)?

This semester is my first programming class (and probably last) and I am really struggling to complete this last project. I honestly have no idea how to even start on this.

The assignment is in C (not C++)and is actually due tonight, but I can turn it in for late credit, so something is better than nothing, but again, I don't even know where to start.

If someone could solve this and post it for me as an example I would be incredibly grateful. I promise that I'm not going to directly copy it, but having an example that I can learn from has always been my most efficient way to learn, so I that's how I would use it.

Here's the problem:

5. (15 pts) Write a recursive function called sum_primes() that accepts an unsigned integer, n, as an argument, and returns the sum of all primes from 2 to n. You must use recursion to solve this problem!


Please help, I'm desperate!

Thanks in advance!

-Spencer

I need C programming help asap! (Problem #2)?

This semester is my first programming class (and probably last) and I am really struggling to complete this last project. I honestly have no idea how to even start on this.

The assignment is in C (not C++)and is actually due tonight, but I can turn it in for late credit, so something is better than nothing, but again, I don't even know where to start.

If someone could solve this and post it for me as an example I would be incredibly grateful. I promise that I'm not going to directly copy it, but having an example that I can learn from has always been my most efficient way to learn, so I that's how I would use it.

Here's the problem:

2. (10 pts) Recall Binary Search:

Input: a list of n sorted integer values and a target value
Output: True if target value exists in list and location of target value, false otherwise
Method:
Set left to 1 and right to n
Set found to false
Set targetindex to -1
While found is false and left is less than or equal to right
Set mid to midpoint between left and right
If target = item at mid then set found to true and set targetindex to mid
If target < item then set right to mid – 1
If target > item then set to left to mid + 1
Return the targetindex

Write a C function called binary_search().


Please help, I'm desperate!

Thanks in advance!

-Spencer

TRENDING NEWS